efform_onload = function ()
{
};  

button_query_onclick = function () 
{   	
	efgrid.submitInqu( "ef_grid_result", "ZM","ZMCH20","query");
}

button_update_onclick = function (){ 
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		var ks = grid.getCellValueByColumnName(rows[i],"fdHoleDeep");
		var bf = grid.getCellValueByColumnName(rows[i],"fdHoleBf");
		var kk = grid.getCellValueByColumnName(rows[i],"fdHoleKk");
		var pj = grid.getCellValueByColumnName(rows[i],"fdHolePj");
		var cg = grid.getCellValueByColumnName(rows[i],"fdHoleCg");
		if(ks<=0&&bf<=0&&kk<=0&&pj<=0&&cg<=0)
		{
			EFAlert("孔深、报废、扩孔、平距、垂高不能同时为零！"); return;
		}
		
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("已经上报的记录，不能再次修改！"); return;
		}
	}
	efgrid.submitForm( "ef_grid_result", "ZM","ZMCH20","update",true);
}

button_insert_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		var ks = grid.getCellValueByColumnName(rows[i],"fdHoleDeep");
		var bf = grid.getCellValueByColumnName(rows[i],"fdHoleBf");
		var kk = grid.getCellValueByColumnName(rows[i],"fdHoleKk");
		var pj = grid.getCellValueByColumnName(rows[i],"fdHolePj");
		var cg = grid.getCellValueByColumnName(rows[i],"fdHoleCg");
		if(ks<=0&&bf<=0&&kk<=0&&pj<=0&&cg<=0)
		{
			EFAlert("孔深、报废、扩孔、平距、垂高不能同时为零！"); return;
		}		
	}
	efgrid.submitForm( "ef_grid_result", "ZM","ZMCH20","insert",true);
}

button_delete_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行删除！"); return;
		}
	}
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM","ZMCH20","delete",true);
	}); 
}
button_report_onclick = function (){  
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("已经上报的记录，不能再次上报！"); return;
		}
	}
	EFConfirm('你确认要上报吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM","ZMCH20","report",true);
	});
}

efgrid_afterAddNewRow = function(grid_id) {
	var grid = efgrid.getGridObject(grid_id);
	var rows = grid.getCheckedRows();
	if (grid_id == "ef_grid_result") {
		for (var i = 0; i < rows.length; i++) {
			grid.getBlockData().setCell(rows[i], "fdKeyId", "");
			grid.getBlockData().setCell(rows[i], "fdStatus", "草拟");
			grid.getBlockData().setCell(rows[i], "fdCurrentDate", getCurrentDate());
		}
	}
}

